package edu.pku.sei.transformation.atl.adapter;

import edu.pku.sei.modeler.model.core.MetaNamedElement;
import edu.pku.sei.modeler.model.core.MetaPackage;
import edu.pku.sei.transformation.atl.rule.IATLType;
import edu.pku.sei.transformation.editor.model.MetaModel;

public class ATLModelTypeAdapter implements IATLType {
	MetaNamedElement type = null;

	public ATLModelTypeAdapter(MetaNamedElement type) {
		this.type = type;
	}

	@Override
	public String getName() {
		MetaNamedElement element = type;
		String name = element.getName();
		while (element.getContainer() instanceof MetaPackage) {
			element = (MetaNamedElement) element.getContainer();
			name = element.getName() + "." + name;
		}
		if (element.getContainer() instanceof MetaModel) {
			element = (MetaNamedElement) element.getContainer();
			name = element.getName() + "!" + name;
		}
		return name;
	}

}
